class code3 {
    //如果count[i]>1就出窗口
    public int lengthOfLongestSubstring(String s) {
        int left = 0;
        int right = 0;
        int[] hash = new int[128];
        char[] ss = s.toCharArray();
        int ret = 0;

        while(right < s.length()) {
            //进窗口
            hash[ss[right]]++;
            //判断
            while(hash[ss[right]] > 1) {
                //出窗口
                hash[ss[left++]]--;
            }
            ret = Math.max(ret,right-left+1);
            right++;
        }
        return ret;
    }
}